home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / System / BoingBag1 / Contributions / InstallerNG / GUI-API / example / igui_QueryDisplay.c < prev    next >
C/C++ Source or Header  |  1999-10-28  |  3KB  |  104 lines

  1.  
  2. #include "includes.h"
  3. #include "installergui_data.h"
  4.  
  5. /********************************************************************
  6.  *
  7.  *  DESCRIPTION
  8.  *
  9.  *  the QUERYDISPLAY function of the InstallerNG (and the original
  10.  *  installer v44+) calls this function to examine the screen or
  11.  *  window of the GUI. see the include file libraries/installergui.h
  12.  *  for more details.
  13.  *
  14.  *  IN:  application - pointer to the private application structure
  15.  *       object - the object to be examined (GUI_QUERYOBJ_SCREEN or
  16.  *                GUI_QUERYOBJ_WINDOW are the only valid values)
  17.  *       attribute - the attribute of the object
  18.  *
  19.  *  OUT: the value of the attribute of the examined object
  20.  *
  21.  */
  22.  
  23. /********************************************************************
  24.  *
  25.  *  STATIC
  26.  *
  27.  */
  28.  
  29. /********************************************************************
  30.  *
  31.  *  EXTERN
  32.  *
  33.  */
  34.  
  35. /********************************************************************
  36.  *
  37.  *  PUBLIC
  38.  *
  39.  */
  40.  
  41. /********************************************************************
  42.  *
  43.  *  CODE
  44.  *
  45.  */
  46.  
  47. long __asm igui_QueryDisplay(register __a0 APTR application,
  48.                              register __d0 long object,
  49.                              register __d1 long attribute)
  50. {
  51.   #ifdef DEBUG
  52.   DEBUG_MAKRO
  53.   #endif
  54.  
  55.   {
  56.     long retval = 0;
  57.     struct Application *app = application;
  58.  
  59.     struct Screen *scr;
  60.     struct Window *win;
  61.  
  62.     // get the pointers to the structures
  63.     GetAttr(MUIA_Window_Screen, app->app_MainWindow, (ULONG *) &scr);
  64.     GetAttr(MUIA_Window_Window, app->app_MainWindow, (ULONG *) &win);
  65.  
  66.     // which object (screen or window)
  67.     switch (object)
  68.     {
  69.       // get a screen attribute
  70.       case GUI_QUERYOBJ_SCREEN:
  71.       {
  72.         switch (attribute)
  73.         {
  74.           case GUI_QUERYATTR_WIDTH:    { retval = scr->Width; break; }
  75.           case GUI_QUERYATTR_HEIGHT:   { retval = scr->Height; break; }
  76.           case GUI_QUERYATTR_DEPTH:    { retval = scr->BitMap.Depth; break; }
  77.           case GUI_QUERYATTR_COLORS:   { retval = 1<<(scr->BitMap.Depth); break; }
  78.         }
  79.  
  80.         break;
  81.       }
  82.  
  83.       // get a window attribute
  84.       case GUI_QUERYOBJ_WINDOW:
  85.       {
  86.         switch (attribute)
  87.         {
  88.           case GUI_QUERYATTR_WIDTH:    { retval = win->Width; break; }
  89.           case GUI_QUERYATTR_HEIGHT:   { retval = win->Height; break; }
  90.           case GUI_QUERYATTR_UPPER:    { retval = win->TopEdge - scr->BarHeight - 1; break; }
  91.           case GUI_QUERYATTR_LOWER:    { retval = scr->Height - (win->TopEdge + win->Height); break; }
  92.           case GUI_QUERYATTR_LEFT:     { retval = win->LeftEdge; break; }
  93.           case GUI_QUERYATTR_RIGHT:    { retval = scr->Width - (win->LeftEdge + win->Width); break; }
  94.         }
  95.  
  96.         break;
  97.       }
  98.     }
  99.  
  100.     return (retval);
  101.   }
  102. }
  103.  
  104.